DLSS.Results = Ext.extend(Ext.Panel, {
    constructor:function(){
        
        //var roundsStore = this.roundsStore;
        var roundsGrid = new Ext.grid.EditorGridPanel({
            cellCls:'round-management-table',
            store: DLSS.roundsStore,
            cm: DLSS.roundsColumnModel,
            width:500,
            height:250,
            autoExpandColumn:'number',
            title:'Rounds',
            frame:true,
            viewConfig: {
                forceFit: true
            }
        });

		//var dancesStore = this.dancesStore;
        var dancesGrid = new Ext.grid.EditorGridPanel({
            cellCls:'dance-management-table',
            store: DLSS.categDancesStore,
            cm: DLSS.dancesColumnModel,
            width:300,
            height:200,
            style:'margin-top:20px;',
            autoExpandColumn:'name',
            title:'Dances',
            frame:true,
            viewConfig: {
                forceFit: true
            }
        });

        //var adjudicatorsStore = this.adjudicatorsStore;
        var resultsForm = new Ext.FormPanel({
	        id: 'results-form',
	        frame: true,
	        labelAlign: 'left',
	        title: DLSS.getMessage('results_grid_title'),
	        bodyStyle:'padding:5px',
	        style:'margin-left:20px; margin-top:20px;',
            width: 700,
	        height: 200,
	        layout: 'column',	// Specifies that the items will now be arranged in columns
	        items: [{
	            columnWidth: 0.6,
	            layout: 'fit',
	            items: {
		            xtype: 'grid',
		            ds: DLSS.categAdjudicatorsStore,
		            cm: DLSS.adjudicatorsColumnModel,
		            sm: new Ext.grid.RowSelectionModel({
		                singleSelect: true,
		                listeners: {
		                    rowselect: function(sm, row, rec) {
		                        Ext.getCmp("results-form").getForm().loadRecord(rec);
		                    }
		                }
		            }),
		            viewConfig: {forceFit: true},
		            //autoExpandColumn: 'letter',
		            height: 170,
		            width: 500,
		            title:DLSS.getMessage('adjudicators_grid_title'),
		            border: true
			        /*listeners: {
			        	render: function(g) {
			        		g.getSelectionModel().selectRow(0);
			        	},
			        	delay: 10 // Allow rows to be rendered.
			        }*/
	        	}
	        },{
	        	columnWidth: 0.2,
	            title:DLSS.getMessage('results_panel_title'),
	            defaults: {width: 100},	// Default config options for child items
	            defaultType: 'checkbox',
	            autoHeight: true,
	            bodyStyle: Ext.isIE ? 'padding:0 0 5px 15px;' : 'padding:10px 15px;',
	            border: false,
	            style: {
	                "margin-left": "10px", // when you add custom margin in IE 6...
	                "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0"  // you have to adjust for it somewhere else
	            },
	            items: [{
	                xtype: 'checkbox',
	                name: '21',
	                boxLabel: '21'
	            },{
	                xtype: 'checkbox',
	                name: '22',
	                boxLabel: '22'
	            },{
	                xtype: 'checkbox',
	                name: '24',
	                boxLabel: '24'
	            },{
	                xtype: 'checkbox',
	                name: '28',
	                boxLabel: '28'
	            }]
	        }
	       ]
	    });
    
    	this.danceResultPanel = new Ext.Panel({
			frame:false,
			border:false,
			layout:'table',
			layoutConfig:{
   				columns:2
			},
			items:[
                dancesGrid,
                resultsForm
			]
		});
		
        DLSS.Results.superclass.constructor.call(this,{
            frame:false,
            header:false,
            border:false,
            bodyStyle:'padding:10px;',
            items:[
                roundsGrid,
				this.danceResultPanel
            ],
            tbar:DLSS.COMPONENTS_ROOT.getToolBarForPage(1)
        });

        this.on('show',function() {
            DLSS.roundsStore.load();
            DLSS.categDancesStore.load();
            DLSS.categAdjudicatorsStore.load();
        },this);

    }
    
});

